package org.alex.nettychat.netty.custom.console;

import io.netty.channel.Channel;
import org.alex.nettychat.netty.custom.protocol.LoginRequestPacket;

import java.util.Scanner;

/**
 * @author : alex
 */
public class Login implements ConsoleCommand{
    @Override
    public void exec(Scanner scanner, Channel channel) {
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        System.out.println("请输入用户id");
        int userId = Integer.parseInt(scanner.nextLine());
        loginRequestPacket.setUserId(userId);
        System.out.println("请输入用户名");
        String userName = scanner.nextLine();
        loginRequestPacket.setUsername(userName);
        loginRequestPacket.setPassword("111");
        channel.writeAndFlush(loginRequestPacket);
    }
}
